import React, {Component} from 'react';
import {Actions} from 'react-native-router-flux';
import {
    Platform,
    Image,
    View,

} from 'react-native';
import styles from "../utils/StylesUtils";
import {colorTheme} from "../utils/ColorUtils";
import TimerMixin from 'react-timer-mixin';
import SplashScreen from '../ui/native/SplashNative'

export default class WelcomePage extends Component {
    render() {
        return (
            <View style={[styles.matchScreen, styles.layoutVTC, styles.gravityCenter, {backgroundColor: colorTheme}]}>
                <Image
                    style={
                        {
                            width: 66,
                            height: 58,
                        }
                    }
                    source={require("../../res/images/icon_rn.png")}
                />
            </View>
        );
    }

    mixins: [TimerMixin];

    /**
     * 加载完毕之后调用
     */
    componentDidMount() {
        if (Platform.OS === 'android') {
            SplashScreen.hide();
        }

        /**
         * 参数一是一个函数
         * 参数二是持续时长
         * @type {number}
         */
        this.timer = setTimeout(
            () => {
                Actions.reset("MainTabPage");
            },
            200
        );
    }

    /**
     * 记得要在图形卸载是同时清除Timer相关事件
     */
    componentWillUnMount() {
        this.timer && clearTimeout(this.timer);
    }
}